package com.wutu.nbyjk8.listener;

import com.alibaba.excel.annotation.ExcelProperty;

import java.lang.reflect.Field;
import java.util.Map;

public class HeadPropertiesConverter {

    public static Map<String, String> getHeadProperty(Map<String, String> propHead, Class<?> clazz) {
        Field[] fields = clazz.getDeclaredFields();     //方式二：Field[] fields = ReflectUtil.getFields(clazz);

        if (fields.length == 0) {
            return null;
        }
        for (Field field : fields) {
            if (field.getAnnotation(ExcelProperty.class) != null) {
                propHead.put(field.getAnnotation(ExcelProperty.class).value()[0], field.getName());
            }
        }
        return propHead;
    }

}
